<template>
  <el-button-group class="ct-tool-list">
<!--     <el-tooltip effect="dark" content="移动" placement="top">
      <el-button size="mini" type="primary" icon="el-icon-circle-plus-outline"></el-button>
    </el-tooltip> -->
    <el-tooltip effect="dark" content="删除" placement="top">
      <el-button size="mini" type="primary" icon="el-icon-delete" @click="handlerDel"></el-button>
    </el-tooltip>
    <el-tooltip effect="dark" content="锁定" placement="top">
      <el-button size="mini" type="primary" icon="el-icon-lock"></el-button>
    </el-tooltip>
  </el-button-group>
</template>
<script type="text/javascript">
// import empty from './empty.vue'
export default {
  components: {
    //empty
  },
  props:{
    value:[Object,Array],
    index:Number,
  },
  data() {
    return {

    }
  },
  /**
   * 计算属性
   * @type {Object}
   */
  computed: {

  },
  /**
   * 数据监听
   * @type {Object}
   */
  watch: {

  },
  /**
   * 页面加载执行
   * @return {[type]} [description]
   */
  mounted() {

  },
  /**
   * 页面方法
   * @type {Object}
   */
  methods: {
    /**
     * 删除该列
     * @return {[type]} [description]
     */
    handlerDel(){
      if(this.value.length > 1){
        this.$confirm('删除之后将不可恢复布局, 是否继续?', '系统提示', {
          confirmButtonText: '继续',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.value.splice(this.index,1);
          var num = parseInt(24 / this.value.length);
          var remain = 24 % this.value.length;
          this.value.forEach(item => {
            item.attribute.span = num
          })
          if(remain > 0){
            this.value[this.value.length -1].attribute.span = num+remain;
          }

          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      }else{
          this.$message({
            type: 'warning',
            message: '最后一列不可删除！'
          }); 
      }
    }

  }
}

</script>
<style type="text/css" lang="scss">
</style>
